<?php

namespace App\Http\Controllers;

use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Routing\Controller as BaseController;

class Controller extends BaseController
{
    use AuthorizesRequests, DispatchesJobs, ValidatesRequests;

    protected function success($msg = 'ok', $data = [], $ext = [])
    {
        return response()->json([
            'code' => 1,
            'msg'  => $msg,
            'data' => $data,
            'ext'  => $ext,
        ])->throwResponse();
    }

    public function error($msg = 'ok', $data = [], $ext = [])
    {
        return response()->json([
            'code' => 0,
            'msg'  => $msg,
            'data' => $data,
            'ext'  => $ext,
        ])->throwResponse();
    }

    public function result($code = 1, $msg = 'ok', $data = [], $ext = [])
    {
        return response()->json([
            'code' => $code,
            'msg'  => $msg,
            'data' => $data,
            'ext'  => $ext,
        ], $code)->throwResponse();
    }
}
